package com.geline.sqlbackup.util;

import com.geline.sqlbackup.bean.InformationTable;

import javax.sql.DataSource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author: mengx
 * @date: 2021/10/23 15:05
 */
public class DataSourceTableUtil {

    /**
     * 查询所有表名列表
     * @param dataSource
     * @return
     */
    public static List<String> getTableList(DataSource dataSource){
        List<InformationTable> informationTableList = SqlInformationUtils.getInformationTableList(dataSource);
        List<String> allTableList = informationTableList.stream().map(row -> row.getTableName()).collect(Collectors.toList());
        return allTableList;
    }
}
